<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="./css/kaoshi.css">
        <script src="./js/jquery.js"></script>
        <script src="./js/layer/layer.js"></script>
    </head>
    <body class="whole">
        <div class="login-interface">
            <img src="./img/kaoshi_back.png">
            <div class="opration">
                <select id="select"> 
                    <option value="3">学生</option>
                    <option value="2">教师</option>
                    <option value="1">管理员</option>
                </select>
                <input type="text" placeholder="输入学号或身份证或姓名..." id="username">
                <input type="password" placeholder="输入密码..." id="password">
                <span id="submit">登录</span>
            </div>
        </div>
        <script>
            $(document).ready(function(){
                var type = 3;
                $('#select').on('change',function(){
                    type = $(this).val();
                    var placeholder = ['','输入管理员账号或密码...','输入教师编号或姓名...','输入学号或身份证或姓名...'][$(this)[0].value];
                    $('#username').attr('placeholder',placeholder);
                });
                $('#submit').on('click',function(){
                    var acc = $('#username').val();
                    var pwd = $('#password').val();
                    $.post('./enter.php',{url_action:'login',type:type,acc:acc,pwd:pwd},function(data){
                        if(data.code){
                            layer.msg(data.msg);
                            var href = ['','./admin-course.php','./teacher-index.php','./student-index.php'];
                            setTimeout(function(){location.href = href[type];},1000);
                        }else{
                            layer.msg(data.msg);
                        }
                    },'JSON')
                });
            });
        </script>
    </body>
</html>